package com.mikey.stream;

import java.util.Arrays;
import java.util.List;

/**
 * @author :Mikey
 * @description :
 * 1.Id必须为偶数
 * 2.年龄大于23
 * 3.用户名转为大写字母
 * 4.用户名倒着排序
 * 5.只输出一个用户
 * @create :2022-09-22 11:15:00
 */
public class Test {
    public static void main(String[] args) {
        User user1 = new User(1,"a",21);
        User user2 = new User(2,"b",22);
        User user3 = new User(3,"c",23);
        User user4 = new User(4,"d",24);
        User user5 = new User(6,"e",25);
        //集合存储
        List<User> users = Arrays.asList(user1, user2, user3, user4, user5);
        //计算交给流
        users.stream()
                .filter(user -> {return user.getId()%2==0;})
                .filter(user -> {return user.getAge()>23;})
                .map(user -> {return user.getName().toUpperCase();})
                .sorted((u1,u2)->{return u2.compareTo(u1);})
                .limit(1)
                .forEach(System.out::println);
    }
}
